﻿using System.Collections.Generic;
using Model;

namespace SoundConstructor
{
	class DeleteSoundCommand : Command
	{
		private string soundName;
		private List<OnetimeSound> onetimeSounds;
		private List<RepeatedSound> repeatedSounds;

		public DeleteSoundCommand(string soundName, List<OnetimeSound> onetimeSounds, List<RepeatedSound> repeatedSounds)
		{
			this.soundName = soundName;
			this.onetimeSounds = onetimeSounds;
			this.repeatedSounds = repeatedSounds;
		}

		public void Execute()
		{
			DeleteOnetimeSound();
			DeleteRepeatedSound();
		}

		private void DeleteOnetimeSound()
		{
			foreach (OnetimeSound sound in onetimeSounds)
			{
				if (sound.Name == soundName)
				{
					onetimeSounds.Remove(sound);
					return;
				}
			}
		}

		private void DeleteRepeatedSound()
		{
			foreach (RepeatedSound sound in repeatedSounds)
			{
				if (sound.Name == soundName)
				{
					repeatedSounds.Remove(sound);
					return;
				}
			}
		}
	}
}
